package com.vhall.component.entity.room.enums;

import lombok.Getter;
import org.apache.commons.collections.map.HashedMap;

import java.util.Map;

/**
 * LiveRoomTypeEnum-
 * 直播类型 1 直播 2 假直播 3 点播
 *
 * @author xing.wang
 * @date 2022/9/27
 */
@Getter
public enum LiveRoomTypeEnum {

    /**
     * 页面叫互动直播
     */
    LIVE_BROADCAST(1, "直播"),

    /**
     * 页面叫纯直播、视频直播、录制直播
     */
    FAKE_LIVE_BROADCAST(2, "假直播"),

    /**
     * 点播
     */
    ON_DEMAND(3, "点播"),

    ;


    private Integer type;
    private String describe;

    LiveRoomTypeEnum(Integer type, String describe) {
        this.type = type;
        this.describe = describe;
    }

    private static Map<Integer, String> kv = new HashedMap(8);

    static {
        for (LiveRoomTypeEnum value : values()) {
            kv.put(value.type, value.describe);
        }
    }

    /**
     * 通过状态获取到类型描述
     *
     * @param status 状态
     * @return 描述
     */
    public static String getDescribe(Integer status) {
        return kv.getOrDefault(status, "");
    }

    public static LiveRoomTypeEnum parse(Integer value) {
        for (LiveRoomTypeEnum anEnum : LiveRoomTypeEnum.values()) {
            if (anEnum.getType().equals(value)) {
                return anEnum;
            }
        }
        return null;
    }
}
